<?php
    session_start();
    if(! isset($_SESSION['username'])) {
        header('Location:index.html');
    }

    ?>

<?php 
include('conn.php');

$sql = "select * from xiaoxi  where flag=0 and username='".
$_SESSION['username']."' order by id desc";
          
   $rs = mysqli_query($link, $sql); //执行sql查询
   $row = mysqli_fetch_assoc($rs);
   foreach ( $conn->query($sql) as $row);

?>




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的信息</title>
     <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="./font/iconfont.css">
<script src="./font/iconfont.js"></script>
    <style>
.icon {
            width: 1em;
            height: 1em;
            vertical-align: -0.15em;
            fill: currentColor;
            overflow: hidden;
            font-size: 14px;
            margin-right:5px;
}
        .div{
            position: relative;
            text-align: center;
            padding-left: 500px;
        }
        .font{
            font-size: 16px;
            font-weight: bold;;
        }
        form{
            font-weight:bold;
            position: relative;
        }
.sousuok {
 height:60px;
        width:300px; 
       
     



}
.sousuo {
        background: url(./images/sous.png);
        width: 51px;
        height: 51px;
        border-style: none;
 position: absolute;
       top: -20px;
 left: 270px;

      

    }
#zcl {
text-align: center;
background-color:#bfd0fa
}
th {

line-height: 45px;
}
img{
border: 1px solid #7492f6;
}
 #fh{
        font-size: 24px;
        float: right;
       line-height: 50px;
        color: darkgray;
    }
#fhw{
font-size: 16px;
line-height: 54px;
float: right;
}
.box{
   color:#999;
 font-size: 12px;
   text-align: center;
}
.ss{
 color:#999;
 font-size: 8px;
}
 
 .yi{
        font-size: 20px;
        float: right;
       line-height: 70px;
        color: darkgray;
    }
#send {
  width: 45px;
  outline: none;
  border: none;
  background: rgb(0, 132, 255);
  height: 20px;
  cursor: pointer;
  color: #fff;
  border-radius: 20px;
  font: bold 14px '宋体';
  transition: all 0.5s;
  margin-top: 30px;
}


    </style>

</head>
<body>
<div style="text-align: center">
<?php
include ("menu.php");
?>

		<br>
			<? if($_SESSION['img']==''){?>  
			<a href="https://jq.qq.com/?_wv=1027&k=qCPXle6A"><img src="img/logo.jpg" width="80" /></a> 
			<?}else{?>
			<a href="https://jq.qq.com/?_wv=1027&k=qCPXle6A"><img class="yuanxing" src="<?echo $_SESSION['img'];?>" width="80" style="border-radius: 50px; border: 1px solid #7492f6; width:100px;height:100px;margin: 5px 5px 5px 0;padding: 2px;
    position: absolute;
    border-radius: 50px;


" /></a>  
			<?}?>
		 
		  </div>
 @<?=$_SESSION['nicheng']?>
<br>
<input id="send" type="button" onclick="javascript:location.reload();" value="刷新">

<br>
</br>
		  <table class="table table-bordered table-hover" id="tableContent">
            <tr></tr>
            <!-- 内容区 -->
		  </table>

  </div>
 </body>
<script>

function doDel(id) {
            if(confirm('确认删除此条消息?')) {
                window.location='delx.php?action=del&id='+id;
            }
        }


    
function getMsgList(){
    $.get('/msgList.php',function(e){
        const data = JSON.parse(e)
        let dataVal = data.data;
        let divElement = ''
        for (let index = 0; index < dataVal.length; index++) {
            const element = dataVal[index];
            let a = `
                <span class='yy'>
                <tr>
                <th>
            `

            if(element['duiimg'] == ''){
                a += `<img class="yuanxing" src="img/logo.jpg" width="80" style="border-radius: 5px; width:50px;height:50px;margin: 5px 5px 5px 0;
        position: absolute;
        border-radius: 5px;" />`;
            }else{
                a += `<img class="yuanxing" src="`+element['duiimg']+`" width="80" style="border-radius: 50%; border: 1px solid #7492f6;padding: 1px; width:70px;height:70px;margin: 5px 5px 5px 0;
        position: absolute;
        border-radius: 5px;" />`;
            }

            a += "&nbsp;"+element['zj'];
            a += `&nbsp;&nbsp;<span class="ss">`+element['ss'];
           
            a += `
            </span>
<span class="yi">>></span>
<br>
            `

            a+= `
            <span class="box">
`+element['nr']+`
<span id="fh">
<span id="fhw">
            `

            a+= `<a href='hf.php?zj=`+element['zj']+` && nr=`+element['nr']+`'>回复</a>&nbsp;&nbsp;`;
            a+= `<a href='javascript:void(0);' onclick='doDel(`+element['id']+`)'>删除</a>`

            a+= `
            </span</span>
</span>

</th>
</tr>
            `

            divElement += a;
            

        }
console.log('访问成功')

        $('#tableContent').html(divElement)


         $('.box').slideUp(0)
$(".yi").click(function() {
   // 2. 当前的元素变化背景颜色
// 3. 其余的兄弟去掉背景颜色 隐式迭代
$(this).siblings(".box").slideToggle(2000);
 });

    })


    
}


$(function() {
    getMsgList();
    //

    setInterval(() => {
        getMsgList();
    }, 12000);
})
</script>
</html>
 

